package cn.huiyunche.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.huiyunche.base.service.interfaces.AdminUserService;
import cn.huiyunche.base.service.vo.Result;
import cn.huiyunche.base.service.vo.SysAdminUserVo;

/**
 * 用户管理
 * @author hdy [Tuffy]
 *
 */
@Controller
@RequestMapping("/user")
public class AdminUserController {
	
	@Autowired
	private AdminUserService adminUserService = null;
	
	/**
	 * 获取所有用户
	 * @return
	 */
	@RequestMapping(method= RequestMethod.GET)
	@ResponseBody
	public Result<List<SysAdminUserVo>> all() {
		return this.getAdminUserService().all();
	}
	
	/**
	 * 获取所有用户
	 * @return
	 */
	@RequestMapping(value = "/edit", method= RequestMethod.POST)
	@ResponseBody
	public Result<String> save(SysAdminUserVo sauv) {
		return this.getAdminUserService().save(sauv);
	}
	
	/**
	 * 获取所有用户
	 * @return
	 */
	@RequestMapping(value = "/delete", method= RequestMethod.POST)
	@ResponseBody
	public Result<String> remove(Long id) {
		return this.getAdminUserService().remove(id);
	}
	
	/**
	 * 获取所有用户
	 * @return
	 */
	@RequestMapping(value = "/{id}", method= RequestMethod.GET)
	@ResponseBody
	public Result<SysAdminUserVo> byId(@PathVariable Long id) {
		return this.getAdminUserService().byId(id);
	}
	
	private AdminUserService getAdminUserService() {
		return this.adminUserService;
	}
}
